﻿package client;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;

import server.CompanyInterface;
import server.EnterpriceInterface;
import server.SaleComInterface;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.rmi.Naming;

public class SaleComInfo_GUI extends JDialog {

	private final JPanel contentPanel = new JPanel();

	/**
	 * Launch the application.
	 *//*
	public static void main(String[] args) {
		try {
			SaleComInfo_GUI dialog = new SaleComInfo_GUI();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public SaleComInfo_GUI() {
		setTitle("\u516C\u53F8\u57FA\u672C\u4FE1\u606F");
		setModalityType(ModalityType.APPLICATION_MODAL);
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel label = new JLabel("\u540D\u79F0\uFF1A");
			label.setBounds(47, 10, 54, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u516C\u53F8\u94F6\u884C\u8D26\u6237\uFF1A");
			label.setBounds(47, 35, 108, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u8D26\u6237\u8D44\u91D1\uFF1A");
			label.setBounds(47, 60, 72, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u8D37\u6B3E\u91D1\u989D\uFF1A");
			label.setBounds(47, 85, 72, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u8D37\u6B3E\u989D\u4E0A\u9650\uFF1A");
			label.setBounds(47, 110, 93, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u804C\u5DE5\u4EBA\u6570\uFF1A");
			label.setBounds(47, 135, 72, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u804C\u5458\u4EBA\u6570\u4E0A\u9650\uFF1A");
			label.setBounds(47, 160, 108, 15);
			contentPanel.add(label);
		}
		{
			JLabel label = new JLabel("\u5E02\u573A\u8C03\u67E5\u8C03\u7528\u8D44\u91D1\uFF1A");
			label.setBounds(47, 185, 117, 15);
			contentPanel.add(label);
		}
		
	
		try
		{
			Configuration config=new Configuration();
			String rmiAddress=config.getRmiAddress();
			
			SaleComInterface SCI=(SaleComInterface) Naming.lookup(rmiAddress+"SaleCom");
			CompanyInterface CI=(CompanyInterface) Naming.lookup(rmiAddress+"Company");
			EnterpriceInterface EI=(EnterpriceInterface) Naming.lookup(rmiAddress+"Enterprice");
			//JOptionPane.showMessageDialog(null, EI.getName(EnterSaleCom_GUI.ComID));
		{
			
			JLabel label = new JLabel(EI.getName(EnterSaleCom_GUI.ComID));
			label.setBounds(171, 10, 86, 15);				
			contentPanel.add(label);
		}
		{
			String bai =String.valueOf(EI.getBankAccountID(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(bai);
			label.setBounds(171, 35, 86, 15);
			contentPanel.add(label);
		}
		{
			String f =String.valueOf(CI.getFounds(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(f);
			label.setBounds(171, 60, 86, 15);
			contentPanel.add(label);
		}
		{
			String lv=String.valueOf(CI.getLoanVal(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(lv);
			label.setBounds(171, 85, 86, 15);
			contentPanel.add(label);
		}
		{
			String mlv=String.valueOf(CI.getMaxLoanVal(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(mlv);
			label.setBounds(171, 110, 86, 15);
			contentPanel.add(label);
		}
		{
			String sn=String.valueOf(CI.getStaffNum(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(sn);
			label.setBounds(171, 135, 86, 15);
			contentPanel.add(label);
		}
		{
			String ms=String.valueOf(CI.getMaxStaff(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(ms);
			label.setBounds(171, 160, 86, 15);
			contentPanel.add(label);
		}
		{
			String mrv=String.valueOf(SCI.getMaxMaxketResFounds(EnterSaleCom_GUI.ComID));
			JLabel label = new JLabel(mrv);
			label.setBounds(171, 185, 86, 15);
			contentPanel.add(label);
		}
		
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						dispose();
						SaleComWorker_3_GUI dialog = new SaleComWorker_3_GUI();
						dialog.setLocationRelativeTo(null);
						dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
						dialog.setVisible(true);
					}
				});
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

}
